package com.bw.myincome.controller;

import com.bw.common.security.utils.SecurityUtils;
import com.bw.myincome.domain.Order;
import com.bw.myincome.service.MyInconmeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 云计算-维度健康-05-我的收入-设计文档-马春洋V1.1-20250115
 */
@RestController
@RequestMapping("/myincome")
public class MyIncomeController {
    @Autowired
    private MyInconmeService myInconmeService;


    @GetMapping("/getMyIncomeList")
    public List<Order> getRevenueList() {
        Integer id = Math.toIntExact(SecurityUtils.getUserId());
        return myInconmeService.getMyIncomeList(id);
    }
    /**
     * 查询总订单数和总收入
     */
    @GetMapping("/getTotal")
    public Order getTotal() {
        Integer id = Math.toIntExact(SecurityUtils.getUserId());
        return myInconmeService.getTotal(id);
    }
    /**
     * 查询某医生的订单记录
     */
    @PostMapping("/getOrderList")
    public List<Order> getOrderList(@RequestBody Order order) {
        Integer id = Math.toIntExact(SecurityUtils.getUserId());
        order.setDoctorId(id);
        return myInconmeService.getOrderList(order);
    }
    /**
     * 查询医生下的订单详情
     */
    @GetMapping("/getOrderDetails")
    public Order getOrderDetails(Integer orderId) {
        Integer id = Math.toIntExact(SecurityUtils.getUserId());
        return myInconmeService.getOrderDetails(id,orderId);
    }

    @PostMapping("/getOrderList2")
    public List<Order> getOrderList2(@RequestBody Order order) {
        Integer id = Math.toIntExact(SecurityUtils.getUserId());
        order.setDoctorId(id);
        return myInconmeService.getOrderList2(order);
    }
}
